/**
 * @Project Name:blog-authentication-server
 * @Package Name:cn.hoofungson.blog.authentication.server.config
 * @Since JDK 1.8
 */

package cn.hoofungson.blog.authentication.server.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;

import javax.sql.DataSource;

/**
 * @Description: WebConfig
 * @Author 胡松 hoofungson@163.com
 * @Date 2020-01-17 11:10
 * @Version V1.0
 */
@Slf4j
@Configuration
public class WebConfig {

    @Autowired
    private DataSource dataSource;

    /****/
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Bean
    public JdbcClientDetailsService jdbcClientDetailsService() {
        JdbcClientDetailsService clientDetailsService = new JdbcClientDetailsService(dataSource);
        log.info("Create ClientDetailsService :: " + clientDetailsService);
        return clientDetailsService;
    }
}
